﻿#region Using directives

using System;
using System.Data;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;

using GPSTrackingDBV2.Entities;
using GPSTrackingDBV2.Data;

#endregion

namespace GPSTrackingDBV2.Data.Bases
{	
	///<summary>
	/// This class is the base class for any <see cref="UsersProviderBase"/> implementation.
	/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
	///</summary>
	public abstract partial class UsersProviderBaseCore : EntityProviderBase<GPSTrackingDBV2.Entities.Users, GPSTrackingDBV2.Entities.UsersKey>
	{		
		#region Get from Many To Many Relationship Functions
		#region GetByGeoFenceIdFromNotificationByGeoFencesByGpsStock
		
		/// <summary>
		///		Gets Users objects from the datasource by GeoFenceID in the
		///		NotificationByGeoFencesByGPSStock table. Table Users is related to table GeoFences
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="_geoFenceId"></param>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByGeoFenceIdFromNotificationByGeoFencesByGpsStock(System.Int32 _geoFenceId)
		{
			int count = -1;
			return GetByGeoFenceIdFromNotificationByGeoFencesByGpsStock(null,_geoFenceId, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets GPSTrackingDBV2.Entities.Users objects from the datasource by GeoFenceID in the
		///		NotificationByGeoFencesByGPSStock table. Table Users is related to table GeoFences
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_geoFenceId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of Users objects.</returns>
		public TList<Users> GetByGeoFenceIdFromNotificationByGeoFencesByGpsStock(System.Int32 _geoFenceId, int start, int pageLength)
		{
			int count = -1;
			return GetByGeoFenceIdFromNotificationByGeoFencesByGpsStock(null, _geoFenceId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets Users objects from the datasource by GeoFenceID in the
		///		NotificationByGeoFencesByGPSStock table. Table Users is related to table GeoFences
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_geoFenceId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByGeoFenceIdFromNotificationByGeoFencesByGpsStock(TransactionManager transactionManager, System.Int32 _geoFenceId)
		{
			int count = -1;
			return GetByGeoFenceIdFromNotificationByGeoFencesByGpsStock(transactionManager, _geoFenceId, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets Users objects from the datasource by GeoFenceID in the
		///		NotificationByGeoFencesByGPSStock table. Table Users is related to table GeoFences
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_geoFenceId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByGeoFenceIdFromNotificationByGeoFencesByGpsStock(TransactionManager transactionManager, System.Int32 _geoFenceId,int start, int pageLength)
		{
			int count = -1;
			return GetByGeoFenceIdFromNotificationByGeoFencesByGpsStock(transactionManager, _geoFenceId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets Users objects from the datasource by GeoFenceID in the
		///		NotificationByGeoFencesByGPSStock table. Table Users is related to table GeoFences
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="_geoFenceId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByGeoFenceIdFromNotificationByGeoFencesByGpsStock(System.Int32 _geoFenceId,int start, int pageLength, out int count)
		{
			
			return GetByGeoFenceIdFromNotificationByGeoFencesByGpsStock(null, _geoFenceId, start, pageLength, out count);
		}


		/// <summary>
		///		Gets Users objects from the datasource by GeoFenceID in the
		///		NotificationByGeoFencesByGPSStock table. Table Users is related to table GeoFences
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="_geoFenceId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of Users objects.</returns>
		public abstract TList<Users> GetByGeoFenceIdFromNotificationByGeoFencesByGpsStock(TransactionManager transactionManager,System.Int32 _geoFenceId, int start, int pageLength, out int count);
		
		#endregion GetByGeoFenceIdFromNotificationByGeoFencesByGpsStock
		
		#region GetByGpsImeiFromNotificationByGeoFencesByGpsStock
		
		/// <summary>
		///		Gets Users objects from the datasource by GPSImei in the
		///		NotificationByGeoFencesByGPSStock table. Table Users is related to table GPSStock
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="_gpsImei"></param>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByGpsImeiFromNotificationByGeoFencesByGpsStock(System.String _gpsImei)
		{
			int count = -1;
			return GetByGpsImeiFromNotificationByGeoFencesByGpsStock(null,_gpsImei, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets GPSTrackingDBV2.Entities.Users objects from the datasource by GPSImei in the
		///		NotificationByGeoFencesByGPSStock table. Table Users is related to table GPSStock
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_gpsImei"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of Users objects.</returns>
		public TList<Users> GetByGpsImeiFromNotificationByGeoFencesByGpsStock(System.String _gpsImei, int start, int pageLength)
		{
			int count = -1;
			return GetByGpsImeiFromNotificationByGeoFencesByGpsStock(null, _gpsImei, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets Users objects from the datasource by GPSImei in the
		///		NotificationByGeoFencesByGPSStock table. Table Users is related to table GPSStock
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_gpsImei"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByGpsImeiFromNotificationByGeoFencesByGpsStock(TransactionManager transactionManager, System.String _gpsImei)
		{
			int count = -1;
			return GetByGpsImeiFromNotificationByGeoFencesByGpsStock(transactionManager, _gpsImei, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets Users objects from the datasource by GPSImei in the
		///		NotificationByGeoFencesByGPSStock table. Table Users is related to table GPSStock
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_gpsImei"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByGpsImeiFromNotificationByGeoFencesByGpsStock(TransactionManager transactionManager, System.String _gpsImei,int start, int pageLength)
		{
			int count = -1;
			return GetByGpsImeiFromNotificationByGeoFencesByGpsStock(transactionManager, _gpsImei, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets Users objects from the datasource by GPSImei in the
		///		NotificationByGeoFencesByGPSStock table. Table Users is related to table GPSStock
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="_gpsImei"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByGpsImeiFromNotificationByGeoFencesByGpsStock(System.String _gpsImei,int start, int pageLength, out int count)
		{
			
			return GetByGpsImeiFromNotificationByGeoFencesByGpsStock(null, _gpsImei, start, pageLength, out count);
		}


		/// <summary>
		///		Gets Users objects from the datasource by GPSImei in the
		///		NotificationByGeoFencesByGPSStock table. Table Users is related to table GPSStock
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="_gpsImei"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of Users objects.</returns>
		public abstract TList<Users> GetByGpsImeiFromNotificationByGeoFencesByGpsStock(TransactionManager transactionManager,System.String _gpsImei, int start, int pageLength, out int count);
		
		#endregion GetByGpsImeiFromNotificationByGeoFencesByGpsStock
		
		#region GetByNotificationIdFromNotificationByGeoFencesByGpsStock
		
		/// <summary>
		///		Gets Users objects from the datasource by NotificationID in the
		///		NotificationByGeoFencesByGPSStock table. Table Users is related to table Notifications
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="_notificationId"></param>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByNotificationIdFromNotificationByGeoFencesByGpsStock(System.Int32 _notificationId)
		{
			int count = -1;
			return GetByNotificationIdFromNotificationByGeoFencesByGpsStock(null,_notificationId, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets GPSTrackingDBV2.Entities.Users objects from the datasource by NotificationID in the
		///		NotificationByGeoFencesByGPSStock table. Table Users is related to table Notifications
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_notificationId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of Users objects.</returns>
		public TList<Users> GetByNotificationIdFromNotificationByGeoFencesByGpsStock(System.Int32 _notificationId, int start, int pageLength)
		{
			int count = -1;
			return GetByNotificationIdFromNotificationByGeoFencesByGpsStock(null, _notificationId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets Users objects from the datasource by NotificationID in the
		///		NotificationByGeoFencesByGPSStock table. Table Users is related to table Notifications
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_notificationId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByNotificationIdFromNotificationByGeoFencesByGpsStock(TransactionManager transactionManager, System.Int32 _notificationId)
		{
			int count = -1;
			return GetByNotificationIdFromNotificationByGeoFencesByGpsStock(transactionManager, _notificationId, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets Users objects from the datasource by NotificationID in the
		///		NotificationByGeoFencesByGPSStock table. Table Users is related to table Notifications
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_notificationId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByNotificationIdFromNotificationByGeoFencesByGpsStock(TransactionManager transactionManager, System.Int32 _notificationId,int start, int pageLength)
		{
			int count = -1;
			return GetByNotificationIdFromNotificationByGeoFencesByGpsStock(transactionManager, _notificationId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets Users objects from the datasource by NotificationID in the
		///		NotificationByGeoFencesByGPSStock table. Table Users is related to table Notifications
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="_notificationId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByNotificationIdFromNotificationByGeoFencesByGpsStock(System.Int32 _notificationId,int start, int pageLength, out int count)
		{
			
			return GetByNotificationIdFromNotificationByGeoFencesByGpsStock(null, _notificationId, start, pageLength, out count);
		}


		/// <summary>
		///		Gets Users objects from the datasource by NotificationID in the
		///		NotificationByGeoFencesByGPSStock table. Table Users is related to table Notifications
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="_notificationId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of Users objects.</returns>
		public abstract TList<Users> GetByNotificationIdFromNotificationByGeoFencesByGpsStock(TransactionManager transactionManager,System.Int32 _notificationId, int start, int pageLength, out int count);
		
		#endregion GetByNotificationIdFromNotificationByGeoFencesByGpsStock
		
		#region GetByCompanyIdStockFileIdFromStockFilesByUsername
		
		/// <summary>
		///		Gets Users objects from the datasource by CompanyID in the
		///		StockFilesByUsername table. Table Users is related to table StockFiles
		///		through the (M:N) relationship defined in the StockFilesByUsername table.
		/// </summary>
		/// <param name="_companyId"></param>
		/// <param name="_stockFileId"></param>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByCompanyIdStockFileIdFromStockFilesByUsername(System.Int32 _companyId, System.Int32 _stockFileId)
		{
			int count = -1;
			return GetByCompanyIdStockFileIdFromStockFilesByUsername(null,_companyId, _stockFileId, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets GPSTrackingDBV2.Entities.Users objects from the datasource by CompanyID in the
		///		StockFilesByUsername table. Table Users is related to table StockFiles
		///		through the (M:N) relationship defined in the StockFilesByUsername table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_companyId"></param>
		/// <param name="_stockFileId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of Users objects.</returns>
		public TList<Users> GetByCompanyIdStockFileIdFromStockFilesByUsername(System.Int32 _companyId, System.Int32 _stockFileId, int start, int pageLength)
		{
			int count = -1;
			return GetByCompanyIdStockFileIdFromStockFilesByUsername(null, _companyId, _stockFileId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets Users objects from the datasource by CompanyID in the
		///		StockFilesByUsername table. Table Users is related to table StockFiles
		///		through the (M:N) relationship defined in the StockFilesByUsername table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_companyId"></param>
		/// <param name="_stockFileId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByCompanyIdStockFileIdFromStockFilesByUsername(TransactionManager transactionManager, System.Int32 _companyId, System.Int32 _stockFileId)
		{
			int count = -1;
			return GetByCompanyIdStockFileIdFromStockFilesByUsername(transactionManager, _companyId, _stockFileId, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets Users objects from the datasource by CompanyID in the
		///		StockFilesByUsername table. Table Users is related to table StockFiles
		///		through the (M:N) relationship defined in the StockFilesByUsername table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_companyId"></param>
		/// <param name="_stockFileId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByCompanyIdStockFileIdFromStockFilesByUsername(TransactionManager transactionManager, System.Int32 _companyId, System.Int32 _stockFileId,int start, int pageLength)
		{
			int count = -1;
			return GetByCompanyIdStockFileIdFromStockFilesByUsername(transactionManager, _companyId, _stockFileId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets Users objects from the datasource by CompanyID in the
		///		StockFilesByUsername table. Table Users is related to table StockFiles
		///		through the (M:N) relationship defined in the StockFilesByUsername table.
		/// </summary>
		/// <param name="_companyId"></param>
		/// <param name="_stockFileId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByCompanyIdStockFileIdFromStockFilesByUsername(System.Int32 _companyId, System.Int32 _stockFileId,int start, int pageLength, out int count)
		{
			
			return GetByCompanyIdStockFileIdFromStockFilesByUsername(null, _companyId, _stockFileId, start, pageLength, out count);
		}


		/// <summary>
		///		Gets Users objects from the datasource by CompanyID in the
		///		StockFilesByUsername table. Table Users is related to table StockFiles
		///		through the (M:N) relationship defined in the StockFilesByUsername table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="_companyId"></param>
		/// <param name="_stockFileId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of Users objects.</returns>
		public abstract TList<Users> GetByCompanyIdStockFileIdFromStockFilesByUsername(TransactionManager transactionManager,System.Int32 _companyId, System.Int32 _stockFileId, int start, int pageLength, out int count);
		
		#endregion GetByCompanyIdStockFileIdFromStockFilesByUsername
		
		#region GetByCompanyIdUserRolesIdFromUserRolesByUsers
		
		/// <summary>
		///		Gets Users objects from the datasource by CompanyID in the
		///		UserRolesByUsers table. Table Users is related to table UserRoles
		///		through the (M:N) relationship defined in the UserRolesByUsers table.
		/// </summary>
		/// <param name="_companyId"></param>
		/// <param name="_userRolesId"></param>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByCompanyIdUserRolesIdFromUserRolesByUsers(System.Int32 _companyId, System.Int32 _userRolesId)
		{
			int count = -1;
			return GetByCompanyIdUserRolesIdFromUserRolesByUsers(null,_companyId, _userRolesId, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets GPSTrackingDBV2.Entities.Users objects from the datasource by CompanyID in the
		///		UserRolesByUsers table. Table Users is related to table UserRoles
		///		through the (M:N) relationship defined in the UserRolesByUsers table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_companyId"></param>
		/// <param name="_userRolesId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of Users objects.</returns>
		public TList<Users> GetByCompanyIdUserRolesIdFromUserRolesByUsers(System.Int32 _companyId, System.Int32 _userRolesId, int start, int pageLength)
		{
			int count = -1;
			return GetByCompanyIdUserRolesIdFromUserRolesByUsers(null, _companyId, _userRolesId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets Users objects from the datasource by CompanyID in the
		///		UserRolesByUsers table. Table Users is related to table UserRoles
		///		through the (M:N) relationship defined in the UserRolesByUsers table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_companyId"></param>
		/// <param name="_userRolesId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByCompanyIdUserRolesIdFromUserRolesByUsers(TransactionManager transactionManager, System.Int32 _companyId, System.Int32 _userRolesId)
		{
			int count = -1;
			return GetByCompanyIdUserRolesIdFromUserRolesByUsers(transactionManager, _companyId, _userRolesId, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets Users objects from the datasource by CompanyID in the
		///		UserRolesByUsers table. Table Users is related to table UserRoles
		///		through the (M:N) relationship defined in the UserRolesByUsers table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_companyId"></param>
		/// <param name="_userRolesId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByCompanyIdUserRolesIdFromUserRolesByUsers(TransactionManager transactionManager, System.Int32 _companyId, System.Int32 _userRolesId,int start, int pageLength)
		{
			int count = -1;
			return GetByCompanyIdUserRolesIdFromUserRolesByUsers(transactionManager, _companyId, _userRolesId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets Users objects from the datasource by CompanyID in the
		///		UserRolesByUsers table. Table Users is related to table UserRoles
		///		through the (M:N) relationship defined in the UserRolesByUsers table.
		/// </summary>
		/// <param name="_companyId"></param>
		/// <param name="_userRolesId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByCompanyIdUserRolesIdFromUserRolesByUsers(System.Int32 _companyId, System.Int32 _userRolesId,int start, int pageLength, out int count)
		{
			
			return GetByCompanyIdUserRolesIdFromUserRolesByUsers(null, _companyId, _userRolesId, start, pageLength, out count);
		}


		/// <summary>
		///		Gets Users objects from the datasource by CompanyID in the
		///		UserRolesByUsers table. Table Users is related to table UserRoles
		///		through the (M:N) relationship defined in the UserRolesByUsers table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="_companyId"></param>
		/// <param name="_userRolesId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of Users objects.</returns>
		public abstract TList<Users> GetByCompanyIdUserRolesIdFromUserRolesByUsers(TransactionManager transactionManager,System.Int32 _companyId, System.Int32 _userRolesId, int start, int pageLength, out int count);
		
		#endregion GetByCompanyIdUserRolesIdFromUserRolesByUsers
		
		#region GetByGpsGroupIdFromUsersByGpsGroups
		
		/// <summary>
		///		Gets Users objects from the datasource by GPSGroupID in the
		///		UsersByGPSGroups table. Table Users is related to table GPSGroups
		///		through the (M:N) relationship defined in the UsersByGPSGroups table.
		/// </summary>
		/// <param name="_gpsGroupId"></param>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByGpsGroupIdFromUsersByGpsGroups(System.Int32 _gpsGroupId)
		{
			int count = -1;
			return GetByGpsGroupIdFromUsersByGpsGroups(null,_gpsGroupId, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets GPSTrackingDBV2.Entities.Users objects from the datasource by GPSGroupID in the
		///		UsersByGPSGroups table. Table Users is related to table GPSGroups
		///		through the (M:N) relationship defined in the UsersByGPSGroups table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_gpsGroupId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of Users objects.</returns>
		public TList<Users> GetByGpsGroupIdFromUsersByGpsGroups(System.Int32 _gpsGroupId, int start, int pageLength)
		{
			int count = -1;
			return GetByGpsGroupIdFromUsersByGpsGroups(null, _gpsGroupId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets Users objects from the datasource by GPSGroupID in the
		///		UsersByGPSGroups table. Table Users is related to table GPSGroups
		///		through the (M:N) relationship defined in the UsersByGPSGroups table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_gpsGroupId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByGpsGroupIdFromUsersByGpsGroups(TransactionManager transactionManager, System.Int32 _gpsGroupId)
		{
			int count = -1;
			return GetByGpsGroupIdFromUsersByGpsGroups(transactionManager, _gpsGroupId, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets Users objects from the datasource by GPSGroupID in the
		///		UsersByGPSGroups table. Table Users is related to table GPSGroups
		///		through the (M:N) relationship defined in the UsersByGPSGroups table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_gpsGroupId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByGpsGroupIdFromUsersByGpsGroups(TransactionManager transactionManager, System.Int32 _gpsGroupId,int start, int pageLength)
		{
			int count = -1;
			return GetByGpsGroupIdFromUsersByGpsGroups(transactionManager, _gpsGroupId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets Users objects from the datasource by GPSGroupID in the
		///		UsersByGPSGroups table. Table Users is related to table GPSGroups
		///		through the (M:N) relationship defined in the UsersByGPSGroups table.
		/// </summary>
		/// <param name="_gpsGroupId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByGpsGroupIdFromUsersByGpsGroups(System.Int32 _gpsGroupId,int start, int pageLength, out int count)
		{
			
			return GetByGpsGroupIdFromUsersByGpsGroups(null, _gpsGroupId, start, pageLength, out count);
		}


		/// <summary>
		///		Gets Users objects from the datasource by GPSGroupID in the
		///		UsersByGPSGroups table. Table Users is related to table GPSGroups
		///		through the (M:N) relationship defined in the UsersByGPSGroups table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="_gpsGroupId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of Users objects.</returns>
		public abstract TList<Users> GetByGpsGroupIdFromUsersByGpsGroups(TransactionManager transactionManager,System.Int32 _gpsGroupId, int start, int pageLength, out int count);
		
		#endregion GetByGpsGroupIdFromUsersByGpsGroups
		
		#region GetByGpsImeiFromUsersByGpsStocks
		
		/// <summary>
		///		Gets Users objects from the datasource by GPSImei in the
		///		UsersByGPSStocks table. Table Users is related to table GPSStock
		///		through the (M:N) relationship defined in the UsersByGPSStocks table.
		/// </summary>
		/// <param name="_gpsImei"></param>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByGpsImeiFromUsersByGpsStocks(System.String _gpsImei)
		{
			int count = -1;
			return GetByGpsImeiFromUsersByGpsStocks(null,_gpsImei, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets GPSTrackingDBV2.Entities.Users objects from the datasource by GPSImei in the
		///		UsersByGPSStocks table. Table Users is related to table GPSStock
		///		through the (M:N) relationship defined in the UsersByGPSStocks table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_gpsImei"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of Users objects.</returns>
		public TList<Users> GetByGpsImeiFromUsersByGpsStocks(System.String _gpsImei, int start, int pageLength)
		{
			int count = -1;
			return GetByGpsImeiFromUsersByGpsStocks(null, _gpsImei, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets Users objects from the datasource by GPSImei in the
		///		UsersByGPSStocks table. Table Users is related to table GPSStock
		///		through the (M:N) relationship defined in the UsersByGPSStocks table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_gpsImei"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByGpsImeiFromUsersByGpsStocks(TransactionManager transactionManager, System.String _gpsImei)
		{
			int count = -1;
			return GetByGpsImeiFromUsersByGpsStocks(transactionManager, _gpsImei, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets Users objects from the datasource by GPSImei in the
		///		UsersByGPSStocks table. Table Users is related to table GPSStock
		///		through the (M:N) relationship defined in the UsersByGPSStocks table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_gpsImei"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByGpsImeiFromUsersByGpsStocks(TransactionManager transactionManager, System.String _gpsImei,int start, int pageLength)
		{
			int count = -1;
			return GetByGpsImeiFromUsersByGpsStocks(transactionManager, _gpsImei, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets Users objects from the datasource by GPSImei in the
		///		UsersByGPSStocks table. Table Users is related to table GPSStock
		///		through the (M:N) relationship defined in the UsersByGPSStocks table.
		/// </summary>
		/// <param name="_gpsImei"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByGpsImeiFromUsersByGpsStocks(System.String _gpsImei,int start, int pageLength, out int count)
		{
			
			return GetByGpsImeiFromUsersByGpsStocks(null, _gpsImei, start, pageLength, out count);
		}


		/// <summary>
		///		Gets Users objects from the datasource by GPSImei in the
		///		UsersByGPSStocks table. Table Users is related to table GPSStock
		///		through the (M:N) relationship defined in the UsersByGPSStocks table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="_gpsImei"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of Users objects.</returns>
		public abstract TList<Users> GetByGpsImeiFromUsersByGpsStocks(TransactionManager transactionManager,System.String _gpsImei, int start, int pageLength, out int count);
		
		#endregion GetByGpsImeiFromUsersByGpsStocks
		
		#region GetByUserGroupIdFromUsersByUsersGroups
		
		/// <summary>
		///		Gets Users objects from the datasource by UserGroupID in the
		///		UsersByUsersGroups table. Table Users is related to table UsersGroups
		///		through the (M:N) relationship defined in the UsersByUsersGroups table.
		/// </summary>
		/// <param name="_userGroupId"></param>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByUserGroupIdFromUsersByUsersGroups(System.Int32 _userGroupId)
		{
			int count = -1;
			return GetByUserGroupIdFromUsersByUsersGroups(null,_userGroupId, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets GPSTrackingDBV2.Entities.Users objects from the datasource by UserGroupID in the
		///		UsersByUsersGroups table. Table Users is related to table UsersGroups
		///		through the (M:N) relationship defined in the UsersByUsersGroups table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_userGroupId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of Users objects.</returns>
		public TList<Users> GetByUserGroupIdFromUsersByUsersGroups(System.Int32 _userGroupId, int start, int pageLength)
		{
			int count = -1;
			return GetByUserGroupIdFromUsersByUsersGroups(null, _userGroupId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets Users objects from the datasource by UserGroupID in the
		///		UsersByUsersGroups table. Table Users is related to table UsersGroups
		///		through the (M:N) relationship defined in the UsersByUsersGroups table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_userGroupId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByUserGroupIdFromUsersByUsersGroups(TransactionManager transactionManager, System.Int32 _userGroupId)
		{
			int count = -1;
			return GetByUserGroupIdFromUsersByUsersGroups(transactionManager, _userGroupId, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets Users objects from the datasource by UserGroupID in the
		///		UsersByUsersGroups table. Table Users is related to table UsersGroups
		///		through the (M:N) relationship defined in the UsersByUsersGroups table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_userGroupId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByUserGroupIdFromUsersByUsersGroups(TransactionManager transactionManager, System.Int32 _userGroupId,int start, int pageLength)
		{
			int count = -1;
			return GetByUserGroupIdFromUsersByUsersGroups(transactionManager, _userGroupId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets Users objects from the datasource by UserGroupID in the
		///		UsersByUsersGroups table. Table Users is related to table UsersGroups
		///		through the (M:N) relationship defined in the UsersByUsersGroups table.
		/// </summary>
		/// <param name="_userGroupId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Users objects.</returns>
		public TList<Users> GetByUserGroupIdFromUsersByUsersGroups(System.Int32 _userGroupId,int start, int pageLength, out int count)
		{
			
			return GetByUserGroupIdFromUsersByUsersGroups(null, _userGroupId, start, pageLength, out count);
		}


		/// <summary>
		///		Gets Users objects from the datasource by UserGroupID in the
		///		UsersByUsersGroups table. Table Users is related to table UsersGroups
		///		through the (M:N) relationship defined in the UsersByUsersGroups table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="_userGroupId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of Users objects.</returns>
		public abstract TList<Users> GetByUserGroupIdFromUsersByUsersGroups(TransactionManager transactionManager,System.Int32 _userGroupId, int start, int pageLength, out int count);
		
		#endregion GetByUserGroupIdFromUsersByUsersGroups
		
		#endregion	
		
		#region Delete Methods

		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to delete.</param>
		/// <returns>Returns true if operation suceeded.</returns>
		public override bool Delete(TransactionManager transactionManager, GPSTrackingDBV2.Entities.UsersKey key)
		{
			return Delete(transactionManager, key.Username, key.CompanyId);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="_username">. Primary Key.</param>
		/// <param name="_companyId">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public bool Delete(System.String _username, System.Int32 _companyId)
		{
			return Delete(null, _username, _companyId);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_username">. Primary Key.</param>
		/// <param name="_companyId">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public abstract bool Delete(TransactionManager transactionManager, System.String _username, System.Int32 _companyId);		
		
		#endregion Delete Methods
		
		#region Get By Foreign Key Functions
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_Users_Companies key.
		///		FK_Users_Companies Description: 
		/// </summary>
		/// <param name="_companyId"></param>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.Users objects.</returns>
		public TList<Users> GetByCompanyId(System.Int32 _companyId)
		{
			int count = -1;
			return GetByCompanyId(_companyId, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_Users_Companies key.
		///		FK_Users_Companies Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_companyId"></param>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.Users objects.</returns>
		/// <remarks></remarks>
		public TList<Users> GetByCompanyId(TransactionManager transactionManager, System.Int32 _companyId)
		{
			int count = -1;
			return GetByCompanyId(transactionManager, _companyId, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_Users_Companies key.
		///		FK_Users_Companies Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_companyId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.Users objects.</returns>
		public TList<Users> GetByCompanyId(TransactionManager transactionManager, System.Int32 _companyId, int start, int pageLength)
		{
			int count = -1;
			return GetByCompanyId(transactionManager, _companyId, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_Users_Companies key.
		///		fkUsersCompanies Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_companyId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.Users objects.</returns>
		public TList<Users> GetByCompanyId(System.Int32 _companyId, int start, int pageLength)
		{
			int count =  -1;
			return GetByCompanyId(null, _companyId, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_Users_Companies key.
		///		fkUsersCompanies Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_companyId"></param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.Users objects.</returns>
		public TList<Users> GetByCompanyId(System.Int32 _companyId, int start, int pageLength,out int count)
		{
			return GetByCompanyId(null, _companyId, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_Users_Companies key.
		///		FK_Users_Companies Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_companyId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.Users objects.</returns>
		public abstract TList<Users> GetByCompanyId(TransactionManager transactionManager, System.Int32 _companyId, int start, int pageLength, out int count);
		
		#endregion

		#region Get By Index Functions
		
		/// <summary>
		/// 	Gets a row from the DataSource based on its primary key.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to retrieve.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <returns>Returns an instance of the Entity class.</returns>
		public override GPSTrackingDBV2.Entities.Users Get(TransactionManager transactionManager, GPSTrackingDBV2.Entities.UsersKey key, int start, int pageLength)
		{
			return GetByUsernameCompanyId(transactionManager, key.Username, key.CompanyId, start, pageLength);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the primary key PK_Users index.
		/// </summary>
		/// <param name="_username"></param>
		/// <param name="_companyId"></param>
		/// <returns>Returns an instance of the <see cref="GPSTrackingDBV2.Entities.Users"/> class.</returns>
		public GPSTrackingDBV2.Entities.Users GetByUsernameCompanyId(System.String _username, System.Int32 _companyId)
		{
			int count = -1;
			return GetByUsernameCompanyId(null,_username, _companyId, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_Users index.
		/// </summary>
		/// <param name="_username"></param>
		/// <param name="_companyId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="GPSTrackingDBV2.Entities.Users"/> class.</returns>
		public GPSTrackingDBV2.Entities.Users GetByUsernameCompanyId(System.String _username, System.Int32 _companyId, int start, int pageLength)
		{
			int count = -1;
			return GetByUsernameCompanyId(null, _username, _companyId, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_Users index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_username"></param>
		/// <param name="_companyId"></param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="GPSTrackingDBV2.Entities.Users"/> class.</returns>
		public GPSTrackingDBV2.Entities.Users GetByUsernameCompanyId(TransactionManager transactionManager, System.String _username, System.Int32 _companyId)
		{
			int count = -1;
			return GetByUsernameCompanyId(transactionManager, _username, _companyId, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_Users index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_username"></param>
		/// <param name="_companyId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="GPSTrackingDBV2.Entities.Users"/> class.</returns>
		public GPSTrackingDBV2.Entities.Users GetByUsernameCompanyId(TransactionManager transactionManager, System.String _username, System.Int32 _companyId, int start, int pageLength)
		{
			int count = -1;
			return GetByUsernameCompanyId(transactionManager, _username, _companyId, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_Users index.
		/// </summary>
		/// <param name="_username"></param>
		/// <param name="_companyId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="GPSTrackingDBV2.Entities.Users"/> class.</returns>
		public GPSTrackingDBV2.Entities.Users GetByUsernameCompanyId(System.String _username, System.Int32 _companyId, int start, int pageLength, out int count)
		{
			return GetByUsernameCompanyId(null, _username, _companyId, start, pageLength, out count);
		}
		
				
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_Users index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_username"></param>
		/// <param name="_companyId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns an instance of the <see cref="GPSTrackingDBV2.Entities.Users"/> class.</returns>
		public abstract GPSTrackingDBV2.Entities.Users GetByUsernameCompanyId(TransactionManager transactionManager, System.String _username, System.Int32 _companyId, int start, int pageLength, out int count);
						
		#endregion "Get By Index Functions"
	
		#region Custom Methods
		
		
		#endregion

		#region Helper Functions	
		
		/// <summary>
		/// Fill a TList&lt;Users&gt; From a DataReader.
		/// </summary>
		/// <param name="reader">Datareader</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">number of rows.</param>
		/// <returns>a <see cref="TList&lt;Users&gt;"/></returns>
		public static TList<Users> Fill(IDataReader reader, TList<Users> rows, int start, int pageLength)
		{
			NetTiersProvider currentProvider = DataRepository.Provider;
            bool useEntityFactory = currentProvider.UseEntityFactory;
            bool enableEntityTracking = currentProvider.EnableEntityTracking;
            LoadPolicy currentLoadPolicy = currentProvider.CurrentLoadPolicy;
			Type entityCreationFactoryType = currentProvider.EntityCreationalFactoryType;
			
			// advance to the starting row
			for (int i = 0; i < start; i++)
			{
				if (!reader.Read())
				return rows; // not enough rows, just return
			}
			for (int i = 0; i < pageLength; i++)
			{
				if (!reader.Read())
					break; // we are done
					
				string key = null;
				
				GPSTrackingDBV2.Entities.Users c = null;
				if (useEntityFactory)
				{
					key = new System.Text.StringBuilder("Users")
					.Append("|").Append((System.String)reader[((int)UsersColumn.Username - 1)])
					.Append("|").Append((System.Int32)reader[((int)UsersColumn.CompanyId - 1)]).ToString();
					c = EntityManager.LocateOrCreate<Users>(
					key.ToString(), // EntityTrackingKey
					"Users",  //Creational Type
					entityCreationFactoryType,  //Factory used to create entity
					enableEntityTracking); // Track this entity?
				}
				else
				{
					c = new GPSTrackingDBV2.Entities.Users();
				}
				
				if (!enableEntityTracking ||
					c.EntityState == EntityState.Added ||
					(enableEntityTracking &&
					
						(
							(currentLoadPolicy == LoadPolicy.PreserveChanges && c.EntityState == EntityState.Unchanged) ||
							(currentLoadPolicy == LoadPolicy.DiscardChanges && c.EntityState != EntityState.Unchanged)
						)
					))
				{
					c.SuppressEntityEvents = true;
					c.Username = (System.String)reader[((int)UsersColumn.Username - 1)];
					c.OriginalUsername = c.Username;
					c.CompanyId = (System.Int32)reader[((int)UsersColumn.CompanyId - 1)];
					c.OriginalCompanyId = c.CompanyId;
					c.Password = (System.String)reader[((int)UsersColumn.Password - 1)];
					c.Identification = (System.String)reader[((int)UsersColumn.Identification - 1)];
					c.Name = (System.String)reader[((int)UsersColumn.Name - 1)];
					c.FirstName = (System.String)reader[((int)UsersColumn.FirstName - 1)];
					c.LastName = (System.String)reader[((int)UsersColumn.LastName - 1)];
					c.CountryId = (System.Int32)reader[((int)UsersColumn.CountryId - 1)];
					c.StateId = (System.Int32)reader[((int)UsersColumn.StateId - 1)];
					c.CityId = (System.Int32)reader[((int)UsersColumn.CityId - 1)];
					c.Mobile = (reader.IsDBNull(((int)UsersColumn.Mobile - 1)))?null:(System.String)reader[((int)UsersColumn.Mobile - 1)];
					c.Phone = (reader.IsDBNull(((int)UsersColumn.Phone - 1)))?null:(System.String)reader[((int)UsersColumn.Phone - 1)];
					c.IsActive = (System.Boolean)reader[((int)UsersColumn.IsActive - 1)];
					c.Email = (reader.IsDBNull(((int)UsersColumn.Email - 1)))?null:(System.String)reader[((int)UsersColumn.Email - 1)];
					c.LastTick = (reader.IsDBNull(((int)UsersColumn.LastTick - 1)))?null:(System.Int64?)reader[((int)UsersColumn.LastTick - 1)];
					c.EntityTrackingKey = key;
					c.AcceptChanges();
					c.SuppressEntityEvents = false;
				}
				rows.Add(c);
			}
		return rows;
		}		
		/// <summary>
		/// Refreshes the <see cref="GPSTrackingDBV2.Entities.Users"/> object from the <see cref="IDataReader"/>.
		/// </summary>
		/// <param name="reader">The <see cref="IDataReader"/> to read from.</param>
		/// <param name="entity">The <see cref="GPSTrackingDBV2.Entities.Users"/> object to refresh.</param>
		public static void RefreshEntity(IDataReader reader, GPSTrackingDBV2.Entities.Users entity)
		{
			if (!reader.Read()) return;
			
			entity.Username = (System.String)reader[((int)UsersColumn.Username - 1)];
			entity.OriginalUsername = (System.String)reader["Username"];
			entity.CompanyId = (System.Int32)reader[((int)UsersColumn.CompanyId - 1)];
			entity.OriginalCompanyId = (System.Int32)reader["CompanyID"];
			entity.Password = (System.String)reader[((int)UsersColumn.Password - 1)];
			entity.Identification = (System.String)reader[((int)UsersColumn.Identification - 1)];
			entity.Name = (System.String)reader[((int)UsersColumn.Name - 1)];
			entity.FirstName = (System.String)reader[((int)UsersColumn.FirstName - 1)];
			entity.LastName = (System.String)reader[((int)UsersColumn.LastName - 1)];
			entity.CountryId = (System.Int32)reader[((int)UsersColumn.CountryId - 1)];
			entity.StateId = (System.Int32)reader[((int)UsersColumn.StateId - 1)];
			entity.CityId = (System.Int32)reader[((int)UsersColumn.CityId - 1)];
			entity.Mobile = (reader.IsDBNull(((int)UsersColumn.Mobile - 1)))?null:(System.String)reader[((int)UsersColumn.Mobile - 1)];
			entity.Phone = (reader.IsDBNull(((int)UsersColumn.Phone - 1)))?null:(System.String)reader[((int)UsersColumn.Phone - 1)];
			entity.IsActive = (System.Boolean)reader[((int)UsersColumn.IsActive - 1)];
			entity.Email = (reader.IsDBNull(((int)UsersColumn.Email - 1)))?null:(System.String)reader[((int)UsersColumn.Email - 1)];
			entity.LastTick = (reader.IsDBNull(((int)UsersColumn.LastTick - 1)))?null:(System.Int64?)reader[((int)UsersColumn.LastTick - 1)];
			entity.AcceptChanges();
		}
		
		/// <summary>
		/// Refreshes the <see cref="GPSTrackingDBV2.Entities.Users"/> object from the <see cref="DataSet"/>.
		/// </summary>
		/// <param name="dataSet">The <see cref="DataSet"/> to read from.</param>
		/// <param name="entity">The <see cref="GPSTrackingDBV2.Entities.Users"/> object.</param>
		public static void RefreshEntity(DataSet dataSet, GPSTrackingDBV2.Entities.Users entity)
		{
			DataRow dataRow = dataSet.Tables[0].Rows[0];
			
			entity.Username = (System.String)dataRow["Username"];
			entity.OriginalUsername = (System.String)dataRow["Username"];
			entity.CompanyId = (System.Int32)dataRow["CompanyID"];
			entity.OriginalCompanyId = (System.Int32)dataRow["CompanyID"];
			entity.Password = (System.String)dataRow["Password"];
			entity.Identification = (System.String)dataRow["Identification"];
			entity.Name = (System.String)dataRow["Name"];
			entity.FirstName = (System.String)dataRow["FirstName"];
			entity.LastName = (System.String)dataRow["LastName"];
			entity.CountryId = (System.Int32)dataRow["CountryID"];
			entity.StateId = (System.Int32)dataRow["StateID"];
			entity.CityId = (System.Int32)dataRow["CityID"];
			entity.Mobile = Convert.IsDBNull(dataRow["Mobile"]) ? null : (System.String)dataRow["Mobile"];
			entity.Phone = Convert.IsDBNull(dataRow["Phone"]) ? null : (System.String)dataRow["Phone"];
			entity.IsActive = (System.Boolean)dataRow["IsActive"];
			entity.Email = Convert.IsDBNull(dataRow["Email"]) ? null : (System.String)dataRow["Email"];
			entity.LastTick = Convert.IsDBNull(dataRow["LastTick"]) ? null : (System.Int64?)dataRow["LastTick"];
			entity.AcceptChanges();
		}
		#endregion 
		
		#region DeepLoad Methods
		/// <summary>
		/// Deep Loads the <see cref="IEntity"/> object with criteria based of the child 
		/// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
		/// </summary>
		/// <remarks>
		/// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
		/// </remarks>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">The <see cref="GPSTrackingDBV2.Entities.Users"/> object to load.</param>
		/// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
		/// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
		/// <param name="childTypes">GPSTrackingDBV2.Entities.Users Property Collection Type Array To Include or Exclude from Load</param>
		/// <param name="innerList">A collection of child types for easy access.</param>
	    /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
	    /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
		public override void DeepLoad(TransactionManager transactionManager, GPSTrackingDBV2.Entities.Users entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
		{
			if(entity == null)
				return;

			#region CompanyIdSource	
			if (CanDeepLoad(entity, "Companies|CompanyIdSource", deepLoadType, innerList) 
				&& entity.CompanyIdSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.CompanyId;
				Companies tmpEntity = EntityManager.LocateEntity<Companies>(EntityLocator.ConstructKeyFromPkItems(typeof(Companies), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.CompanyIdSource = tmpEntity;
				else
					entity.CompanyIdSource = DataRepository.CompaniesProvider.GetByCompanyId(transactionManager, entity.CompanyId);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'CompanyIdSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.CompanyIdSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.CompaniesProvider.DeepLoad(transactionManager, entity.CompanyIdSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion CompanyIdSource
			
			//used to hold DeepLoad method delegates and fire after all the local children have been loaded.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();
			// Deep load child collections  - Call GetByUsernameCompanyId methods when available
			
			#region CompanyIdStockFileIdStockFilesCollection_From_StockFilesByUsername
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<StockFiles>|CompanyIdStockFileIdStockFilesCollection_From_StockFilesByUsername", deepLoadType, innerList))
			{
				entity.CompanyIdStockFileIdStockFilesCollection_From_StockFilesByUsername = DataRepository.StockFilesProvider.GetByUsernameCompanyIdFromStockFilesByUsername(transactionManager, entity.Username, entity.CompanyId);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'CompanyIdStockFileIdStockFilesCollection_From_StockFilesByUsername' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.CompanyIdStockFileIdStockFilesCollection_From_StockFilesByUsername != null)
				{
					deepHandles.Add("CompanyIdStockFileIdStockFilesCollection_From_StockFilesByUsername",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< StockFiles >) DataRepository.StockFilesProvider.DeepLoad,
						new object[] { transactionManager, entity.CompanyIdStockFileIdStockFilesCollection_From_StockFilesByUsername, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region GpsImeiGpsStockCollection_From_NotificationByGeoFencesByGpsStock
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<GpsStock>|GpsImeiGpsStockCollection_From_NotificationByGeoFencesByGpsStock", deepLoadType, innerList))
			{
				entity.GpsImeiGpsStockCollection_From_NotificationByGeoFencesByGpsStock = DataRepository.GpsStockProvider.GetByUsernameCompanyIdFromNotificationByGeoFencesByGpsStock(transactionManager, entity.Username, entity.CompanyId);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'GpsImeiGpsStockCollection_From_NotificationByGeoFencesByGpsStock' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.GpsImeiGpsStockCollection_From_NotificationByGeoFencesByGpsStock != null)
				{
					deepHandles.Add("GpsImeiGpsStockCollection_From_NotificationByGeoFencesByGpsStock",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< GpsStock >) DataRepository.GpsStockProvider.DeepLoad,
						new object[] { transactionManager, entity.GpsImeiGpsStockCollection_From_NotificationByGeoFencesByGpsStock, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region UserGroupIdUsersGroupsCollection_From_UsersByUsersGroups
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<UsersGroups>|UserGroupIdUsersGroupsCollection_From_UsersByUsersGroups", deepLoadType, innerList))
			{
				entity.UserGroupIdUsersGroupsCollection_From_UsersByUsersGroups = DataRepository.UsersGroupsProvider.GetByUsernameCompanyIdFromUsersByUsersGroups(transactionManager, entity.Username, entity.CompanyId);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'UserGroupIdUsersGroupsCollection_From_UsersByUsersGroups' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.UserGroupIdUsersGroupsCollection_From_UsersByUsersGroups != null)
				{
					deepHandles.Add("UserGroupIdUsersGroupsCollection_From_UsersByUsersGroups",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< UsersGroups >) DataRepository.UsersGroupsProvider.DeepLoad,
						new object[] { transactionManager, entity.UserGroupIdUsersGroupsCollection_From_UsersByUsersGroups, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region GpsImeiGpsStockCollection_From_UsersByGpsStocks
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<GpsStock>|GpsImeiGpsStockCollection_From_UsersByGpsStocks", deepLoadType, innerList))
			{
				entity.GpsImeiGpsStockCollection_From_UsersByGpsStocks = DataRepository.GpsStockProvider.GetByUsernameCompanyIdFromUsersByGpsStocks(transactionManager, entity.Username, entity.CompanyId);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'GpsImeiGpsStockCollection_From_UsersByGpsStocks' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.GpsImeiGpsStockCollection_From_UsersByGpsStocks != null)
				{
					deepHandles.Add("GpsImeiGpsStockCollection_From_UsersByGpsStocks",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< GpsStock >) DataRepository.GpsStockProvider.DeepLoad,
						new object[] { transactionManager, entity.GpsImeiGpsStockCollection_From_UsersByGpsStocks, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region UsersByGpsStocksCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<UsersByGpsStocks>|UsersByGpsStocksCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'UsersByGpsStocksCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.UsersByGpsStocksCollection = DataRepository.UsersByGpsStocksProvider.GetByUsernameCompanyId(transactionManager, entity.Username, entity.CompanyId);

				if (deep && entity.UsersByGpsStocksCollection.Count > 0)
				{
					deepHandles.Add("UsersByGpsStocksCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<UsersByGpsStocks>) DataRepository.UsersByGpsStocksProvider.DeepLoad,
						new object[] { transactionManager, entity.UsersByGpsStocksCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region OrderCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<Order>|OrderCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'OrderCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.OrderCollection = DataRepository.OrderProvider.GetByUsernameCompanyId(transactionManager, entity.Username, entity.CompanyId);

				if (deep && entity.OrderCollection.Count > 0)
				{
					deepHandles.Add("OrderCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<Order>) DataRepository.OrderProvider.DeepLoad,
						new object[] { transactionManager, entity.OrderCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region NotificationByGeoFencesByGpsStockCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<NotificationByGeoFencesByGpsStock>|NotificationByGeoFencesByGpsStockCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'NotificationByGeoFencesByGpsStockCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.NotificationByGeoFencesByGpsStockCollection = DataRepository.NotificationByGeoFencesByGpsStockProvider.GetByUsernameCompanyId(transactionManager, entity.Username, entity.CompanyId);

				if (deep && entity.NotificationByGeoFencesByGpsStockCollection.Count > 0)
				{
					deepHandles.Add("NotificationByGeoFencesByGpsStockCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<NotificationByGeoFencesByGpsStock>) DataRepository.NotificationByGeoFencesByGpsStockProvider.DeepLoad,
						new object[] { transactionManager, entity.NotificationByGeoFencesByGpsStockCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region UsersByGpsGroupsCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<UsersByGpsGroups>|UsersByGpsGroupsCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'UsersByGpsGroupsCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.UsersByGpsGroupsCollection = DataRepository.UsersByGpsGroupsProvider.GetByUsernameCompanyId(transactionManager, entity.Username, entity.CompanyId);

				if (deep && entity.UsersByGpsGroupsCollection.Count > 0)
				{
					deepHandles.Add("UsersByGpsGroupsCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<UsersByGpsGroups>) DataRepository.UsersByGpsGroupsProvider.DeepLoad,
						new object[] { transactionManager, entity.UsersByGpsGroupsCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region UsersByEmailCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<UsersByEmail>|UsersByEmailCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'UsersByEmailCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.UsersByEmailCollection = DataRepository.UsersByEmailProvider.GetByUsernameCompanyId(transactionManager, entity.Username, entity.CompanyId);

				if (deep && entity.UsersByEmailCollection.Count > 0)
				{
					deepHandles.Add("UsersByEmailCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<UsersByEmail>) DataRepository.UsersByEmailProvider.DeepLoad,
						new object[] { transactionManager, entity.UsersByEmailCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region StockFilesByUsernameCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<StockFilesByUsername>|StockFilesByUsernameCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'StockFilesByUsernameCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.StockFilesByUsernameCollection = DataRepository.StockFilesByUsernameProvider.GetByUsernameCompanyId(transactionManager, entity.Username, entity.CompanyId);

				if (deep && entity.StockFilesByUsernameCollection.Count > 0)
				{
					deepHandles.Add("StockFilesByUsernameCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<StockFilesByUsername>) DataRepository.StockFilesByUsernameProvider.DeepLoad,
						new object[] { transactionManager, entity.StockFilesByUsernameCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region CompanyIdUserRolesIdUserRolesCollection_From_UserRolesByUsers
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<UserRoles>|CompanyIdUserRolesIdUserRolesCollection_From_UserRolesByUsers", deepLoadType, innerList))
			{
				entity.CompanyIdUserRolesIdUserRolesCollection_From_UserRolesByUsers = DataRepository.UserRolesProvider.GetByUsernameCompanyIdFromUserRolesByUsers(transactionManager, entity.Username, entity.CompanyId);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'CompanyIdUserRolesIdUserRolesCollection_From_UserRolesByUsers' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.CompanyIdUserRolesIdUserRolesCollection_From_UserRolesByUsers != null)
				{
					deepHandles.Add("CompanyIdUserRolesIdUserRolesCollection_From_UserRolesByUsers",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< UserRoles >) DataRepository.UserRolesProvider.DeepLoad,
						new object[] { transactionManager, entity.CompanyIdUserRolesIdUserRolesCollection_From_UserRolesByUsers, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region GpsGroupIdGpsGroupsCollection_From_UsersByGpsGroups
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<GpsGroups>|GpsGroupIdGpsGroupsCollection_From_UsersByGpsGroups", deepLoadType, innerList))
			{
				entity.GpsGroupIdGpsGroupsCollection_From_UsersByGpsGroups = DataRepository.GpsGroupsProvider.GetByUsernameCompanyIdFromUsersByGpsGroups(transactionManager, entity.Username, entity.CompanyId);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'GpsGroupIdGpsGroupsCollection_From_UsersByGpsGroups' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.GpsGroupIdGpsGroupsCollection_From_UsersByGpsGroups != null)
				{
					deepHandles.Add("GpsGroupIdGpsGroupsCollection_From_UsersByGpsGroups",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< GpsGroups >) DataRepository.GpsGroupsProvider.DeepLoad,
						new object[] { transactionManager, entity.GpsGroupIdGpsGroupsCollection_From_UsersByGpsGroups, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region UserRolesByUsersCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<UserRolesByUsers>|UserRolesByUsersCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'UserRolesByUsersCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.UserRolesByUsersCollection = DataRepository.UserRolesByUsersProvider.GetByUsernameCompanyId(transactionManager, entity.Username, entity.CompanyId);

				if (deep && entity.UserRolesByUsersCollection.Count > 0)
				{
					deepHandles.Add("UserRolesByUsersCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<UserRolesByUsers>) DataRepository.UserRolesByUsersProvider.DeepLoad,
						new object[] { transactionManager, entity.UserRolesByUsersCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<Notifications>|NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock", deepLoadType, innerList))
			{
				entity.NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock = DataRepository.NotificationsProvider.GetByUsernameCompanyIdFromNotificationByGeoFencesByGpsStock(transactionManager, entity.Username, entity.CompanyId);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock != null)
				{
					deepHandles.Add("NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< Notifications >) DataRepository.NotificationsProvider.DeepLoad,
						new object[] { transactionManager, entity.NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<GeoFences>|GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock", deepLoadType, innerList))
			{
				entity.GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock = DataRepository.GeoFencesProvider.GetByUsernameCompanyIdFromNotificationByGeoFencesByGpsStock(transactionManager, entity.Username, entity.CompanyId);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock != null)
				{
					deepHandles.Add("GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< GeoFences >) DataRepository.GeoFencesProvider.DeepLoad,
						new object[] { transactionManager, entity.GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region ClientsToVisitCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<ClientsToVisit>|ClientsToVisitCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'ClientsToVisitCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.ClientsToVisitCollection = DataRepository.ClientsToVisitProvider.GetByUsernameCompanyId(transactionManager, entity.Username, entity.CompanyId);

				if (deep && entity.ClientsToVisitCollection.Count > 0)
				{
					deepHandles.Add("ClientsToVisitCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<ClientsToVisit>) DataRepository.ClientsToVisitProvider.DeepLoad,
						new object[] { transactionManager, entity.ClientsToVisitCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region UsersByUsersGroupsCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<UsersByUsersGroups>|UsersByUsersGroupsCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'UsersByUsersGroupsCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.UsersByUsersGroupsCollection = DataRepository.UsersByUsersGroupsProvider.GetByUsernameCompanyId(transactionManager, entity.Username, entity.CompanyId);

				if (deep && entity.UsersByUsersGroupsCollection.Count > 0)
				{
					deepHandles.Add("UsersByUsersGroupsCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<UsersByUsersGroups>) DataRepository.UsersByUsersGroupsProvider.DeepLoad,
						new object[] { transactionManager, entity.UsersByUsersGroupsCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			//Fire all DeepLoad Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			deepHandles = null;
		}
		
		#endregion 
		
		#region DeepSave Methods

		/// <summary>
		/// Deep Save the entire object graph of the GPSTrackingDBV2.Entities.Users object with criteria based of the child 
		/// Type property array and DeepSaveType.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entity">GPSTrackingDBV2.Entities.Users instance</param>
		/// <param name="deepSaveType">DeepSaveType Enumeration to Include/Exclude object property collections from Save.</param>
		/// <param name="childTypes">GPSTrackingDBV2.Entities.Users Property Collection Type Array To Include or Exclude from Save</param>
		/// <param name="innerList">A Hashtable of child types for easy access.</param>
		public override bool DeepSave(TransactionManager transactionManager, GPSTrackingDBV2.Entities.Users entity, DeepSaveType deepSaveType, System.Type[] childTypes, DeepSession innerList)
		{	
			if (entity == null)
				return false;
							
			#region Composite Parent Properties
			//Save Source Composite Properties, however, don't call deep save on them.  
			//So they only get saved a single level deep.
			
			#region CompanyIdSource
			if (CanDeepSave(entity, "Companies|CompanyIdSource", deepSaveType, innerList) 
				&& entity.CompanyIdSource != null)
			{
				DataRepository.CompaniesProvider.Save(transactionManager, entity.CompanyIdSource);
				entity.CompanyId = entity.CompanyIdSource.CompanyId;
			}
			#endregion 
			#endregion Composite Parent Properties

			// Save Root Entity through Provider
			if (!entity.IsDeleted)
				this.Save(transactionManager, entity);
			
			//used to hold DeepSave method delegates and fire after all the local children have been saved.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();

			#region CompanyIdStockFileIdStockFilesCollection_From_StockFilesByUsername>
			if (CanDeepSave(entity.CompanyIdStockFileIdStockFilesCollection_From_StockFilesByUsername, "List<StockFiles>|CompanyIdStockFileIdStockFilesCollection_From_StockFilesByUsername", deepSaveType, innerList))
			{
				if (entity.CompanyIdStockFileIdStockFilesCollection_From_StockFilesByUsername.Count > 0 || entity.CompanyIdStockFileIdStockFilesCollection_From_StockFilesByUsername.DeletedItems.Count > 0)
				{
					DataRepository.StockFilesProvider.Save(transactionManager, entity.CompanyIdStockFileIdStockFilesCollection_From_StockFilesByUsername); 
					deepHandles.Add("CompanyIdStockFileIdStockFilesCollection_From_StockFilesByUsername",
						new KeyValuePair<Delegate, object>((DeepSaveHandle<StockFiles>) DataRepository.StockFilesProvider.DeepSave,
						new object[] { transactionManager, entity.CompanyIdStockFileIdStockFilesCollection_From_StockFilesByUsername, deepSaveType, childTypes, innerList }
					));
				}
			}
			#endregion 

			#region GpsImeiGpsStockCollection_From_NotificationByGeoFencesByGpsStock>
			if (CanDeepSave(entity.GpsImeiGpsStockCollection_From_NotificationByGeoFencesByGpsStock, "List<GpsStock>|GpsImeiGpsStockCollection_From_NotificationByGeoFencesByGpsStock", deepSaveType, innerList))
			{
				if (entity.GpsImeiGpsStockCollection_From_NotificationByGeoFencesByGpsStock.Count > 0 || entity.GpsImeiGpsStockCollection_From_NotificationByGeoFencesByGpsStock.DeletedItems.Count > 0)
				{
					DataRepository.GpsStockProvider.Save(transactionManager, entity.GpsImeiGpsStockCollection_From_NotificationByGeoFencesByGpsStock); 
					deepHandles.Add("GpsImeiGpsStockCollection_From_NotificationByGeoFencesByGpsStock",
						new KeyValuePair<Delegate, object>((DeepSaveHandle<GpsStock>) DataRepository.GpsStockProvider.DeepSave,
						new object[] { transactionManager, entity.GpsImeiGpsStockCollection_From_NotificationByGeoFencesByGpsStock, deepSaveType, childTypes, innerList }
					));
				}
			}
			#endregion 

			#region UserGroupIdUsersGroupsCollection_From_UsersByUsersGroups>
			if (CanDeepSave(entity.UserGroupIdUsersGroupsCollection_From_UsersByUsersGroups, "List<UsersGroups>|UserGroupIdUsersGroupsCollection_From_UsersByUsersGroups", deepSaveType, innerList))
			{
				if (entity.UserGroupIdUsersGroupsCollection_From_UsersByUsersGroups.Count > 0 || entity.UserGroupIdUsersGroupsCollection_From_UsersByUsersGroups.DeletedItems.Count > 0)
				{
					DataRepository.UsersGroupsProvider.Save(transactionManager, entity.UserGroupIdUsersGroupsCollection_From_UsersByUsersGroups); 
					deepHandles.Add("UserGroupIdUsersGroupsCollection_From_UsersByUsersGroups",
						new KeyValuePair<Delegate, object>((DeepSaveHandle<UsersGroups>) DataRepository.UsersGroupsProvider.DeepSave,
						new object[] { transactionManager, entity.UserGroupIdUsersGroupsCollection_From_UsersByUsersGroups, deepSaveType, childTypes, innerList }
					));
				}
			}
			#endregion 

			#region GpsImeiGpsStockCollection_From_UsersByGpsStocks>
			if (CanDeepSave(entity.GpsImeiGpsStockCollection_From_UsersByGpsStocks, "List<GpsStock>|GpsImeiGpsStockCollection_From_UsersByGpsStocks", deepSaveType, innerList))
			{
				if (entity.GpsImeiGpsStockCollection_From_UsersByGpsStocks.Count > 0 || entity.GpsImeiGpsStockCollection_From_UsersByGpsStocks.DeletedItems.Count > 0)
				{
					DataRepository.GpsStockProvider.Save(transactionManager, entity.GpsImeiGpsStockCollection_From_UsersByGpsStocks); 
					deepHandles.Add("GpsImeiGpsStockCollection_From_UsersByGpsStocks",
						new KeyValuePair<Delegate, object>((DeepSaveHandle<GpsStock>) DataRepository.GpsStockProvider.DeepSave,
						new object[] { transactionManager, entity.GpsImeiGpsStockCollection_From_UsersByGpsStocks, deepSaveType, childTypes, innerList }
					));
				}
			}
			#endregion 

			#region CompanyIdUserRolesIdUserRolesCollection_From_UserRolesByUsers>
			if (CanDeepSave(entity.CompanyIdUserRolesIdUserRolesCollection_From_UserRolesByUsers, "List<UserRoles>|CompanyIdUserRolesIdUserRolesCollection_From_UserRolesByUsers", deepSaveType, innerList))
			{
				if (entity.CompanyIdUserRolesIdUserRolesCollection_From_UserRolesByUsers.Count > 0 || entity.CompanyIdUserRolesIdUserRolesCollection_From_UserRolesByUsers.DeletedItems.Count > 0)
				{
					DataRepository.UserRolesProvider.Save(transactionManager, entity.CompanyIdUserRolesIdUserRolesCollection_From_UserRolesByUsers); 
					deepHandles.Add("CompanyIdUserRolesIdUserRolesCollection_From_UserRolesByUsers",
						new KeyValuePair<Delegate, object>((DeepSaveHandle<UserRoles>) DataRepository.UserRolesProvider.DeepSave,
						new object[] { transactionManager, entity.CompanyIdUserRolesIdUserRolesCollection_From_UserRolesByUsers, deepSaveType, childTypes, innerList }
					));
				}
			}
			#endregion 

			#region GpsGroupIdGpsGroupsCollection_From_UsersByGpsGroups>
			if (CanDeepSave(entity.GpsGroupIdGpsGroupsCollection_From_UsersByGpsGroups, "List<GpsGroups>|GpsGroupIdGpsGroupsCollection_From_UsersByGpsGroups", deepSaveType, innerList))
			{
				if (entity.GpsGroupIdGpsGroupsCollection_From_UsersByGpsGroups.Count > 0 || entity.GpsGroupIdGpsGroupsCollection_From_UsersByGpsGroups.DeletedItems.Count > 0)
				{
					DataRepository.GpsGroupsProvider.Save(transactionManager, entity.GpsGroupIdGpsGroupsCollection_From_UsersByGpsGroups); 
					deepHandles.Add("GpsGroupIdGpsGroupsCollection_From_UsersByGpsGroups",
						new KeyValuePair<Delegate, object>((DeepSaveHandle<GpsGroups>) DataRepository.GpsGroupsProvider.DeepSave,
						new object[] { transactionManager, entity.GpsGroupIdGpsGroupsCollection_From_UsersByGpsGroups, deepSaveType, childTypes, innerList }
					));
				}
			}
			#endregion 

			#region NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock>
			if (CanDeepSave(entity.NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock, "List<Notifications>|NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock", deepSaveType, innerList))
			{
				if (entity.NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock.Count > 0 || entity.NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock.DeletedItems.Count > 0)
				{
					DataRepository.NotificationsProvider.Save(transactionManager, entity.NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock); 
					deepHandles.Add("NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock",
						new KeyValuePair<Delegate, object>((DeepSaveHandle<Notifications>) DataRepository.NotificationsProvider.DeepSave,
						new object[] { transactionManager, entity.NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock, deepSaveType, childTypes, innerList }
					));
				}
			}
			#endregion 

			#region GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock>
			if (CanDeepSave(entity.GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock, "List<GeoFences>|GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock", deepSaveType, innerList))
			{
				if (entity.GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock.Count > 0 || entity.GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock.DeletedItems.Count > 0)
				{
					DataRepository.GeoFencesProvider.Save(transactionManager, entity.GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock); 
					deepHandles.Add("GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock",
						new KeyValuePair<Delegate, object>((DeepSaveHandle<GeoFences>) DataRepository.GeoFencesProvider.DeepSave,
						new object[] { transactionManager, entity.GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock, deepSaveType, childTypes, innerList }
					));
				}
			}
			#endregion 
	
			#region List<UsersByGpsStocks>
				if (CanDeepSave(entity.UsersByGpsStocksCollection, "List<UsersByGpsStocks>|UsersByGpsStocksCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(UsersByGpsStocks child in entity.UsersByGpsStocksCollection)
					{
						if(child.UsernameCompanyIdSource != null)
						{
								child.Username = child.UsernameCompanyIdSource.Username;
								child.CompanyId = child.UsernameCompanyIdSource.CompanyId;
						}

						if(child.GpsImeiSource != null)
						{
								child.GpsImei = child.GpsImeiSource.GpsImei;
						}

					}

					if (entity.UsersByGpsStocksCollection.Count > 0 || entity.UsersByGpsStocksCollection.DeletedItems.Count > 0)
					{
						//DataRepository.UsersByGpsStocksProvider.Save(transactionManager, entity.UsersByGpsStocksCollection);
						
						deepHandles.Add("UsersByGpsStocksCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< UsersByGpsStocks >) DataRepository.UsersByGpsStocksProvider.DeepSave,
							new object[] { transactionManager, entity.UsersByGpsStocksCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
	
			#region List<Order>
				if (CanDeepSave(entity.OrderCollection, "List<Order>|OrderCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(Order child in entity.OrderCollection)
					{
						if(child.UsernameCompanyIdSource != null)
						{
							child.Username = child.UsernameCompanyIdSource.Username;
							child.CompanyId = child.UsernameCompanyIdSource.CompanyId;
						}
						else
						{
							child.Username = entity.Username;
							child.CompanyId = entity.CompanyId;
						}

					}

					if (entity.OrderCollection.Count > 0 || entity.OrderCollection.DeletedItems.Count > 0)
					{
						//DataRepository.OrderProvider.Save(transactionManager, entity.OrderCollection);
						
						deepHandles.Add("OrderCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< Order >) DataRepository.OrderProvider.DeepSave,
							new object[] { transactionManager, entity.OrderCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
	
			#region List<NotificationByGeoFencesByGpsStock>
				if (CanDeepSave(entity.NotificationByGeoFencesByGpsStockCollection, "List<NotificationByGeoFencesByGpsStock>|NotificationByGeoFencesByGpsStockCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(NotificationByGeoFencesByGpsStock child in entity.NotificationByGeoFencesByGpsStockCollection)
					{
						if(child.UsernameCompanyIdSource != null)
						{
								child.Username = child.UsernameCompanyIdSource.Username;
								child.CompanyId = child.UsernameCompanyIdSource.CompanyId;
						}

						if(child.GpsImeiSource != null)
						{
								child.GpsImei = child.GpsImeiSource.GpsImei;
						}

						if(child.NotificationIdSource != null)
						{
								child.NotificationId = child.NotificationIdSource.NotificationId;
						}

						if(child.GeoFenceIdSource != null)
						{
								child.GeoFenceId = child.GeoFenceIdSource.GeoFenceId;
						}

					}

					if (entity.NotificationByGeoFencesByGpsStockCollection.Count > 0 || entity.NotificationByGeoFencesByGpsStockCollection.DeletedItems.Count > 0)
					{
						//DataRepository.NotificationByGeoFencesByGpsStockProvider.Save(transactionManager, entity.NotificationByGeoFencesByGpsStockCollection);
						
						deepHandles.Add("NotificationByGeoFencesByGpsStockCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< NotificationByGeoFencesByGpsStock >) DataRepository.NotificationByGeoFencesByGpsStockProvider.DeepSave,
							new object[] { transactionManager, entity.NotificationByGeoFencesByGpsStockCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
	
			#region List<UsersByGpsGroups>
				if (CanDeepSave(entity.UsersByGpsGroupsCollection, "List<UsersByGpsGroups>|UsersByGpsGroupsCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(UsersByGpsGroups child in entity.UsersByGpsGroupsCollection)
					{
						if(child.UsernameCompanyIdSource != null)
						{
								child.Username = child.UsernameCompanyIdSource.Username;
								child.CompanyId = child.UsernameCompanyIdSource.CompanyId;
						}

						if(child.GpsGroupIdSource != null)
						{
								child.GpsGroupId = child.GpsGroupIdSource.GpsGroupId;
						}

					}

					if (entity.UsersByGpsGroupsCollection.Count > 0 || entity.UsersByGpsGroupsCollection.DeletedItems.Count > 0)
					{
						//DataRepository.UsersByGpsGroupsProvider.Save(transactionManager, entity.UsersByGpsGroupsCollection);
						
						deepHandles.Add("UsersByGpsGroupsCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< UsersByGpsGroups >) DataRepository.UsersByGpsGroupsProvider.DeepSave,
							new object[] { transactionManager, entity.UsersByGpsGroupsCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
	
			#region List<UsersByEmail>
				if (CanDeepSave(entity.UsersByEmailCollection, "List<UsersByEmail>|UsersByEmailCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(UsersByEmail child in entity.UsersByEmailCollection)
					{
						if(child.UsernameCompanyIdSource != null)
						{
							child.Username = child.UsernameCompanyIdSource.Username;
							child.CompanyId = child.UsernameCompanyIdSource.CompanyId;
						}
						else
						{
							child.Username = entity.Username;
							child.CompanyId = entity.CompanyId;
						}

					}

					if (entity.UsersByEmailCollection.Count > 0 || entity.UsersByEmailCollection.DeletedItems.Count > 0)
					{
						//DataRepository.UsersByEmailProvider.Save(transactionManager, entity.UsersByEmailCollection);
						
						deepHandles.Add("UsersByEmailCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< UsersByEmail >) DataRepository.UsersByEmailProvider.DeepSave,
							new object[] { transactionManager, entity.UsersByEmailCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
	
			#region List<StockFilesByUsername>
				if (CanDeepSave(entity.StockFilesByUsernameCollection, "List<StockFilesByUsername>|StockFilesByUsernameCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(StockFilesByUsername child in entity.StockFilesByUsernameCollection)
					{
						if(child.UsernameCompanyIdSource != null)
						{
								child.Username = child.UsernameCompanyIdSource.Username;
								child.CompanyId = child.UsernameCompanyIdSource.CompanyId;
						}

						if(child.CompanyIdStockFileIdSource != null)
						{
								child.CompanyId = child.CompanyIdStockFileIdSource.CompanyId;
								child.StockFileId = child.CompanyIdStockFileIdSource.StockFileId;
						}

					}

					if (entity.StockFilesByUsernameCollection.Count > 0 || entity.StockFilesByUsernameCollection.DeletedItems.Count > 0)
					{
						//DataRepository.StockFilesByUsernameProvider.Save(transactionManager, entity.StockFilesByUsernameCollection);
						
						deepHandles.Add("StockFilesByUsernameCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< StockFilesByUsername >) DataRepository.StockFilesByUsernameProvider.DeepSave,
							new object[] { transactionManager, entity.StockFilesByUsernameCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
	
			#region List<UserRolesByUsers>
				if (CanDeepSave(entity.UserRolesByUsersCollection, "List<UserRolesByUsers>|UserRolesByUsersCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(UserRolesByUsers child in entity.UserRolesByUsersCollection)
					{
						if(child.UsernameCompanyIdSource != null)
						{
								child.Username = child.UsernameCompanyIdSource.Username;
								child.CompanyId = child.UsernameCompanyIdSource.CompanyId;
						}

						if(child.CompanyIdUserRolesIdSource != null)
						{
								child.CompanyId = child.CompanyIdUserRolesIdSource.CompanyId;
								child.UserRolesId = child.CompanyIdUserRolesIdSource.UserRolesId;
						}

					}

					if (entity.UserRolesByUsersCollection.Count > 0 || entity.UserRolesByUsersCollection.DeletedItems.Count > 0)
					{
						//DataRepository.UserRolesByUsersProvider.Save(transactionManager, entity.UserRolesByUsersCollection);
						
						deepHandles.Add("UserRolesByUsersCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< UserRolesByUsers >) DataRepository.UserRolesByUsersProvider.DeepSave,
							new object[] { transactionManager, entity.UserRolesByUsersCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
	
			#region List<ClientsToVisit>
				if (CanDeepSave(entity.ClientsToVisitCollection, "List<ClientsToVisit>|ClientsToVisitCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(ClientsToVisit child in entity.ClientsToVisitCollection)
					{
						if(child.UsernameCompanyIdSource != null)
						{
							child.Username = child.UsernameCompanyIdSource.Username;
							child.CompanyId = child.UsernameCompanyIdSource.CompanyId;
						}
						else
						{
							child.Username = entity.Username;
							child.CompanyId = entity.CompanyId;
						}

					}

					if (entity.ClientsToVisitCollection.Count > 0 || entity.ClientsToVisitCollection.DeletedItems.Count > 0)
					{
						//DataRepository.ClientsToVisitProvider.Save(transactionManager, entity.ClientsToVisitCollection);
						
						deepHandles.Add("ClientsToVisitCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< ClientsToVisit >) DataRepository.ClientsToVisitProvider.DeepSave,
							new object[] { transactionManager, entity.ClientsToVisitCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
	
			#region List<UsersByUsersGroups>
				if (CanDeepSave(entity.UsersByUsersGroupsCollection, "List<UsersByUsersGroups>|UsersByUsersGroupsCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(UsersByUsersGroups child in entity.UsersByUsersGroupsCollection)
					{
						if(child.UsernameCompanyIdSource != null)
						{
								child.Username = child.UsernameCompanyIdSource.Username;
								child.CompanyId = child.UsernameCompanyIdSource.CompanyId;
						}

						if(child.UserGroupIdSource != null)
						{
								child.UserGroupId = child.UserGroupIdSource.UserGroupId;
						}

					}

					if (entity.UsersByUsersGroupsCollection.Count > 0 || entity.UsersByUsersGroupsCollection.DeletedItems.Count > 0)
					{
						//DataRepository.UsersByUsersGroupsProvider.Save(transactionManager, entity.UsersByUsersGroupsCollection);
						
						deepHandles.Add("UsersByUsersGroupsCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< UsersByUsersGroups >) DataRepository.UsersByUsersGroupsProvider.DeepSave,
							new object[] { transactionManager, entity.UsersByUsersGroupsCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
			//Fire all DeepSave Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			
			// Save Root Entity through Provider, if not already saved in delete mode
			if (entity.IsDeleted)
				this.Save(transactionManager, entity);
				

			deepHandles = null;
						
			return true;
		}
		#endregion
	} // end class
	
	#region UsersChildEntityTypes
	
	///<summary>
	/// Enumeration used to expose the different child entity types 
	/// for child properties in <c>GPSTrackingDBV2.Entities.Users</c>
	///</summary>
	public enum UsersChildEntityTypes
	{
		
		///<summary>
		/// Composite Property for <c>Companies</c> at CompanyIdSource
		///</summary>
		[ChildEntityType(typeof(Companies))]
		Companies,
	
		///<summary>
		/// Collection of <c>Users</c> as ManyToMany for StockFilesCollection_From_StockFilesByUsername
		///</summary>
		[ChildEntityType(typeof(TList<StockFiles>))]
		CompanyIdStockFileIdStockFilesCollection_From_StockFilesByUsername,

		///<summary>
		/// Collection of <c>Users</c> as ManyToMany for GpsStockCollection_From_NotificationByGeoFencesByGpsStock
		///</summary>
		[ChildEntityType(typeof(TList<GpsStock>))]
		GpsImeiGpsStockCollection_From_NotificationByGeoFencesByGpsStock,

		///<summary>
		/// Collection of <c>Users</c> as ManyToMany for UsersGroupsCollection_From_UsersByUsersGroups
		///</summary>
		[ChildEntityType(typeof(TList<UsersGroups>))]
		UserGroupIdUsersGroupsCollection_From_UsersByUsersGroups,

		///<summary>
		/// Collection of <c>Users</c> as ManyToMany for GpsStockCollection_From_UsersByGpsStocks
		///</summary>
		[ChildEntityType(typeof(TList<GpsStock>))]
		GpsImeiGpsStockCollection_From_UsersByGpsStocks,

		///<summary>
		/// Collection of <c>Users</c> as OneToMany for UsersByGpsStocksCollection
		///</summary>
		[ChildEntityType(typeof(TList<UsersByGpsStocks>))]
		UsersByGpsStocksCollection,

		///<summary>
		/// Collection of <c>Users</c> as OneToMany for OrderCollection
		///</summary>
		[ChildEntityType(typeof(TList<Order>))]
		OrderCollection,

		///<summary>
		/// Collection of <c>Users</c> as OneToMany for NotificationByGeoFencesByGpsStockCollection
		///</summary>
		[ChildEntityType(typeof(TList<NotificationByGeoFencesByGpsStock>))]
		NotificationByGeoFencesByGpsStockCollection,

		///<summary>
		/// Collection of <c>Users</c> as OneToMany for UsersByGpsGroupsCollection
		///</summary>
		[ChildEntityType(typeof(TList<UsersByGpsGroups>))]
		UsersByGpsGroupsCollection,

		///<summary>
		/// Collection of <c>Users</c> as OneToMany for UsersByEmailCollection
		///</summary>
		[ChildEntityType(typeof(TList<UsersByEmail>))]
		UsersByEmailCollection,

		///<summary>
		/// Collection of <c>Users</c> as OneToMany for StockFilesByUsernameCollection
		///</summary>
		[ChildEntityType(typeof(TList<StockFilesByUsername>))]
		StockFilesByUsernameCollection,

		///<summary>
		/// Collection of <c>Users</c> as ManyToMany for UserRolesCollection_From_UserRolesByUsers
		///</summary>
		[ChildEntityType(typeof(TList<UserRoles>))]
		CompanyIdUserRolesIdUserRolesCollection_From_UserRolesByUsers,

		///<summary>
		/// Collection of <c>Users</c> as ManyToMany for GpsGroupsCollection_From_UsersByGpsGroups
		///</summary>
		[ChildEntityType(typeof(TList<GpsGroups>))]
		GpsGroupIdGpsGroupsCollection_From_UsersByGpsGroups,

		///<summary>
		/// Collection of <c>Users</c> as OneToMany for UserRolesByUsersCollection
		///</summary>
		[ChildEntityType(typeof(TList<UserRolesByUsers>))]
		UserRolesByUsersCollection,

		///<summary>
		/// Collection of <c>Users</c> as ManyToMany for NotificationsCollection_From_NotificationByGeoFencesByGpsStock
		///</summary>
		[ChildEntityType(typeof(TList<Notifications>))]
		NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock,

		///<summary>
		/// Collection of <c>Users</c> as ManyToMany for GeoFencesCollection_From_NotificationByGeoFencesByGpsStock
		///</summary>
		[ChildEntityType(typeof(TList<GeoFences>))]
		GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock,

		///<summary>
		/// Collection of <c>Users</c> as OneToMany for ClientsToVisitCollection
		///</summary>
		[ChildEntityType(typeof(TList<ClientsToVisit>))]
		ClientsToVisitCollection,

		///<summary>
		/// Collection of <c>Users</c> as OneToMany for UsersByUsersGroupsCollection
		///</summary>
		[ChildEntityType(typeof(TList<UsersByUsersGroups>))]
		UsersByUsersGroupsCollection,
	}
	
	#endregion UsersChildEntityTypes
	
	#region UsersFilterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlFilterBuilder&lt;UsersColumn&gt;"/> class
	/// that is used exclusively with a <see cref="Users"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class UsersFilterBuilder : SqlFilterBuilder<UsersColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the UsersFilterBuilder class.
		/// </summary>
		public UsersFilterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the UsersFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public UsersFilterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the UsersFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public UsersFilterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion UsersFilterBuilder
	
	#region UsersParameterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="ParameterizedSqlFilterBuilder&lt;UsersColumn&gt;"/> class
	/// that is used exclusively with a <see cref="Users"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class UsersParameterBuilder : ParameterizedSqlFilterBuilder<UsersColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the UsersParameterBuilder class.
		/// </summary>
		public UsersParameterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the UsersParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public UsersParameterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the UsersParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public UsersParameterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion UsersParameterBuilder
	
	#region UsersSortBuilder
    
    /// <summary>
    /// A strongly-typed instance of the <see cref="SqlSortBuilder&lt;UsersColumn&gt;"/> class
	/// that is used exclusively with a <see cref="Users"/> object.
    /// </summary>
    [CLSCompliant(true)]
    public class UsersSortBuilder : SqlSortBuilder<UsersColumn>
    {
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the UsersSqlSortBuilder class.
		/// </summary>
		public UsersSortBuilder() : base() { }

		#endregion Constructors

    }    
    #endregion UsersSortBuilder
	
} // end namespace
